home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-28 | 2.7 KB | 130 lines | [TEXT/R*ch] |
- /*
- File: LetterLogWindow.cp
-
- Copyright: © 1991-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Part of the AOCE Sample SMSAM Package. Consult the license
- which came with this software for your specific legal rights.
-
- */
-
-
-
- #ifndef __LETTERLOGWINDOW__
- #include "LetterLogWindow.h"
- #endif
-
- #ifndef __FONTS__
- #include "FONTS.h"
- #endif
-
- #ifndef __MENUS__
- #include <Menus.h>
- #endif
-
- #ifndef __GRAFPORTSAVER__
- #include "GrafPortSaver.h"
- #endif
-
- #ifndef __LETTERLOG__
- #include "LetterLog.h"
- #endif
-
- #ifndef __OBJECTLIST__
- #include "ObjectList.h"
- #endif
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
-
- /***********************************|****************************************/
-
- TLetterLogWindow::TLetterLogWindow ( TLetterLog* log, short windowID ) :
- TLogWindow ( windowID ),
- fLog ( log )
- {
- }
-
- /***********************************|****************************************/
-
- TLetterLogWindow::~TLetterLogWindow ( )
- {
- }
- /***********************************|****************************************/
-
- void TLetterLogWindow::Draw ( ) const
- {
- if ( GetWindowPtr() )
- Draw ( GetWindowPtr()->portRect );
- }
-
- /***********************************|****************************************/
-
-
- void TLetterLogWindow::Draw( const Rect& drawRect ) const
- {
- if ( GetWindowPtr() )
- { CGrafPortSaver saved ( GetWindowPtr () );
- Boolean drewARow = false;
-
- unsigned long count = GetRowCount ();
- for ( unsigned long index = ( drawRect.top / fHeight ) - 1; index <= count ; ++ index )
- { Rect r = GetRectForRow ( index );
-
- if ( ( r.bottom >= drawRect.top ) && ( r.top <= drawRect.bottom ) )
- {
- DrawRow ( index );
- drewARow = true;
- }
- else if ( drewARow )
- break;
- }
- }
- }
-
- /***********************************|****************************************/
-
- void TLetterLogWindow::DrawRow ( unsigned long whichRow ) const
- {
- CGrafPortSaver saved ( GetWindowPtr () );
- TLetterLogEnumerator items ( *fLog );
-
- if ( ( whichRow >= 1 ) && ( whichRow <= items.CountEntries() ) )
- {
- const TLetterLogEntry* entry = items.GetEntryByIndex ( whichRow );
-
- Rect r = GetRectForRow ( whichRow );
-
- if ( entry )
- {
- DrawString ( r.left + 2, r.bottom - 2, entry->fSubject );
- EraseLineTo ( r.left + 120, r.bottom - 2 );
- DrawString ( r.left + 120, r.bottom - 2, entry->fSender );
-
- }
- }
- }
-
- /***********************************|****************************************/
-
- unsigned long TLetterLogWindow::GetRowCount ( ) const
- {
- TLetterLogEnumerator items ( *fLog );
- return items.CountEntries();
- }
-
- /***********************************|****************************************/
-
- unsigned long TLetterLogWindow::GetRowWidth ( ) const
- {
- return 200;
- }
-
- /***********************************|****************************************/
-